import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '@/views/HomeView.vue'
import ModelTestView from '@/views/ModelTestView.vue'
import DemocraticLifeView from '@/views/DemocraticLifeView.vue'
import SummaryMaterialView from '@/views/SummaryMaterialView.vue'
import ReportsView from '@/views/ReportsView.vue'
import PublicityView from '@/views/PublicityView.vue'
import AdministrativeView from '@/views/AdministrativeView.vue'
import SpeechView from '@/views/SpeechView.vue'

// 汇报材料子页面
import JobReportView from '@/views/reports/JobReportView.vue'
import WorkReportView from '@/views/reports/WorkReportView.vue'
import ExperienceView from '@/views/reports/ExperienceView.vue'

// 宣传材料子页面
import NewsView from '@/views/publicity/NewsView.vue'

// 行政公文子页面
import LetterView from '@/views/administrative/LetterView.vue'
import CommandView from '@/views/administrative/CommandView.vue'
import DecisionView from '@/views/administrative/DecisionView.vue'
import ReplyView from '@/views/administrative/ReplyView.vue'
import NotificationView from '@/views/administrative/NotificationView.vue'
import NoticeView from '@/views/administrative/NoticeView.vue'
import OpinionView from '@/views/administrative/OpinionView.vue'
import RequestView from '@/views/administrative/RequestView.vue'

const routes = [
  {
    path: '/',
    name: 'home',
    component: HomeView,
    meta: {
      title: '首页'
    }
  },
  {
    path: '/materials/democratic-life',
    name: 'democratic-life',
    component: DemocraticLifeView,
    meta: {
      title: '民主生活会材料'
    }
  },
  {
    path: '/materials/summary',
    name: 'summary-material',
    component: SummaryMaterialView,
    meta: {
      title: '总结材料'
    }
  },
  {
    path: '/reports',
    name: 'reports',
    component: ReportsView,
    meta: {
      title: '汇报材料'
    }
  },
  {
    path: '/publicity',
    name: 'publicity',
    component: PublicityView,
    meta: {
      title: '宣传材料'
    }
  },
  {
    path: '/administrative',
    name: 'administrative',
    component: AdministrativeView,
    meta: {
      title: '行政公文'
    }
  },
  {
    path: '/speech',
    name: 'speech',
    component: SpeechView,
    meta: {
      title: '发言稿'
    }
  },
  // 汇报材料子路由
  {
    path: '/reports/job-report',
    name: 'job-report',
    component: JobReportView,
    meta: {
      title: '述职报告'
    }
  },
  {
    path: '/reports/work-report',
    name: 'work-report',
    component: WorkReportView,
    meta: {
      title: '工作汇报'
    }
  },
  {
    path: '/reports/experience',
    name: 'experience',
    component: ExperienceView,
    meta: {
      title: '心得体会'
    }
  },
  // 宣传材料子路由
  {
    path: '/publicity/news',
    name: 'news',
    component: NewsView,
    meta: {
      title: '新闻稿'
    }
  },
  // 行政公文子路由
  {
    path: '/administrative/letter',
    name: 'letter',
    component: LetterView,
    meta: {
      title: '函'
    }
  },
  {
    path: '/administrative/command',
    name: 'command',
    component: CommandView,
    meta: {
      title: '命令'
    }
  },
  {
    path: '/administrative/decision',
    name: 'decision',
    component: DecisionView,
    meta: {
      title: '决定'
    }
  },
  {
    path: '/administrative/reply',
    name: 'reply',
    component: ReplyView,
    meta: {
      title: '批复'
    }
  },
  {
    path: '/administrative/notification',
    name: 'notification',
    component: NotificationView,
    meta: {
      title: '通报'
    }
  },
  {
    path: '/administrative/notice',
    name: 'notice',
    component: NoticeView,
    meta: {
      title: '通知'
    }
  },
  {
    path: '/administrative/opinion',
    name: 'opinion',
    component: OpinionView,
    meta: {
      title: '意见'
    }
  },
  {
    path: '/administrative/request',
    name: 'request',
    component: RequestView,
    meta: {
      title: '请示'
    }
  },
  {
    path: '/model-test',
    name: 'model-test',
    component: ModelTestView,
    meta: {
      title: '模型配置'
    }
  },
  {
    path: '/:pathMatch(.*)*',
    redirect: '/'
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

// 设置页面标题
router.beforeEach((to) => {
  const title = to.meta?.title as string
  if (title) {
    document.title = `${title} - 公务员写作工具`
  }
})

export default router